package com.ithrima.activiti.day03.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.repository.ProcessDefinitionQuery;
import org.activiti.engine.runtime.ProcessInstance;
import org.apache.commons.io.IOUtils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 *   启动流程实例，关联上业务系统
 *      添加buseisskey
 *
 *   本质:act_ru_execution 通过busessionkey标识 与业务系统进行关联
 *
 */
public class bussinessKeyadd {

    public static void main(String[] args) throws IOException {
        //1. 得到ProcessEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        //2. RuntimeServicedui对象
        RuntimeService runtimeService = processEngine.getRuntimeService();
        //3. 启动流程实例，同时制定业务标识bussinessKey
        // 第一个参数：流程定义的key
        // 第二个参数： 业务标识businesskey
        ProcessInstance myProcess_1 = runtimeService.startProcessInstanceByKey("myProcess_1", "1004");
        // 4.输出相关的属性
        System.out.println(myProcess_1.getBusinessKey());
        System.out.println(myProcess_1.getDeploymentId());
        System.out.println(myProcess_1.getProcessDefinitionId());

    }
}
